home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d18 / mou105.arc / MOU.H < prev    next >
Text File  |  1991-09-29  |  6KB  |  160 lines

  1. /*****************************************************************************
  2.  * PROJECT:  Mouse routines with 'real' graphic cursor in text mode.
  3.  *****************************************************************************
  4.  * MODULE:  MOU.H
  5.  *****************************************************************************
  6.  * DESCRIPTION:
  7.  *   Header file for the mouse routines.
  8.  *
  9.  *****************************************************************************
  10.  * MODIFICATION NOTES:
  11.  *    Date     Author Comment
  12.  * 07-Jan-1991   dk   Fixed bugs and set up for release to Usenet.
  13.  * 26-Oct-1990   dk   Initial file.
  14.  *****************************************************************************
  15.  *
  16.  * DISCLAIMER:
  17.  *
  18.  * Programmers may incorporate any or all code into their programs,
  19.  * giving proper credit within the source. Publication of the
  20.  * source routines is permitted so long as proper credit is given
  21.  * to Dave Kirsch.
  22.  *
  23.  * Copyright (C) 1990, 1991 by Dave Kirsch.  You may use this program, or
  24.  * code or tables extracted from it, as desired without restriction.
  25.  * I can not and will not be held responsible for any damage caused from
  26.  * the use of this software.
  27.  *
  28.  *****************************************************************************
  29.  * This source works with Turbo C 2.0 and MSC 6.0 and above.
  30.  *****************************************************************************/
  31.  
  32. /********************************************************/
  33. /* 26-Oct-1990 - dk                                     */
  34. /*                                                      */
  35. /*  Standard types and constants I use in my programs.  */
  36. /*                                                      */
  37. /********************************************************/
  38.  
  39. typedef unsigned char       byte;
  40. typedef unsigned short int  word;
  41. typedef unsigned short int  boolean;
  42. typedef unsigned long  int  dword;
  43.  
  44. #define FALSE 0
  45. #define TRUE (!FALSE)
  46.  
  47. #ifdef __TURBOC__
  48.   #define FAST pascal     /* for fast calling of functions -- Turbo C */
  49. #else
  50.   #define FAST _fastcall  /* for fast calling of functions -- MicroSoft C 6.0 */
  51.   #define asm _asm
  52. #endif
  53. #define LOCAL   near   /* function can not be called outside of this module */
  54. #define PRIVATE static /* function is private */
  55. #define STATIC  static /* private variables */
  56.  
  57. #ifndef MK_FP
  58.   #define MK_FP(seg,ofs)  ((void far *) \
  59.                              (((unsigned long)(seg) << 16) | (unsigned)(ofs)))
  60. #endif
  61.  
  62. #ifndef poke
  63. #define poke(a,b,c)     (*((int  far*)MK_FP((a),(b))) = (int)(c))
  64. #define pokeb(a,b,c)    (*((char far*)MK_FP((a),(b))) = (char)(c))
  65. #define peek(a,b)       (*((int  far*)MK_FP((a),(b))))
  66. #define peekb(a,b)      (*((char far*)MK_FP((a),(b))))
  67. #endif
  68.  
  69. /***************************************************/
  70. /* Mon 07-Jan-1991 - dk                            */
  71. /*                                                 */
  72. /*  Variables and defines for the mouse routines.  */
  73. /*                                                 */
  74. /***************************************************/
  75.  
  76. /* Size of mouse "click" ahead buffer. */
  77. #define MOUSEBUFFERSIZE 16
  78.  
  79. /* Bit defines for mouse driver function 12 -- define handler. */
  80. #define MOUSEMOVE      1
  81. #define LEFTBPRESS     2
  82. #define LEFTBRELEASE   4
  83. #define RIGHTBPRESS    8
  84. #define RIGHTBRELEASE 16
  85. #define MIDBPRESS     32
  86. #define MIDBRELEASE   64
  87.  
  88. #define LEFTBDOWN  1
  89. #define RIGHTBDOWN 2
  90. #define MIDBDOWN   4
  91.  
  92. /* Shift states for byte a 0:417h
  93.    bit 7 =1 INSert active
  94.    bit 6 =1 Caps Lock active
  95.    bit 5 =1 Num Lock active
  96.    bit 4 =1 Scroll Lock active
  97.    bit 3 =1 either Alt pressed
  98.    bit 2 =1 either Ctrl pressed
  99.    bit 1 =1 Left Shift pressed
  100.    bit 0 =1 Right Shift pressed
  101. */
  102.  
  103. #define SHIFT_RIGHTSHIFT 0x01
  104. #define SHIFT_LEFTSHIFT  0x02
  105. #define SHIFT_SHIFT      0x03 /* Either shift key. */
  106. #define SHIFT_CTRL       0x04
  107. #define SHIFT_ALT        0x08
  108. #define SHIFT_SCROLLLOCK 0x10
  109. #define SHIFT_NUMLOCK    0x20
  110. #define SHIFT_CAPSLOCK   0x40
  111. #define SHIFT_INS        0x80
  112.  
  113. /* Mouse information record */
  114. struct minforectype {
  115.   word buttonstat;
  116.   word    cx, cy;
  117.   byte shiftstate;
  118. };
  119.  
  120. #define MOUINFOREC struct minforectype
  121.  
  122. extern word mousehidden;           /* Is the mouse on? Additive flag */
  123. extern boolean mouseinstalled;     /* Is the mouse installed? */
  124.  
  125. extern volatile word mousex, mousey; /* Mouse coordinates in characters. */
  126.  
  127. /* Initialize the mouse routines -- must be called. */
  128. void    FAST MOUinit(void);
  129.  
  130. /* Deinitialize the mouse routines -- must be called on shutdown.
  131.    Failure to call it will most likely result in a system crash if the mouse
  132.    is moved. */
  133. void    FAST MOUdeinit(void);
  134.  
  135. /* Hide the mouse cursor */
  136. void    FAST MOUhide(void);
  137.  
  138. /* Hide the mouse cursor if it moves or is in a specific rectangular region
  139.    of the screen. */
  140. void    FAST MOUconditionalhide(int x1, int y1, int x2, int y2);
  141.  
  142. /* Show the mouse cursor */
  143. void    FAST MOUshow(void);
  144.  
  145. /* return TRUE if there are events waiting in the buffer. */
  146. boolean FAST MOUcheck(void);
  147.  
  148. /* look at the next event in the buffer, but don't pull it out. */
  149. void    FAST MOUpreview(MOUINFOREC *mouinforec);
  150.  
  151. /* get and remove next event from the buffer. */
  152. void    FAST MOUget(MOUINFOREC *mouinforec);
  153.  
  154. /* return the current status of the mouse buttons (see defines above). */
  155. word    FAST MOUbuttonstatus(void);
  156.  
  157. /* Set the mouse cursor to a specific screen position. */
  158. void FAST MOUsetpos(word x, word y);
  159. 
  160.